"use strict";

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DATE } = Sequelize;
    await queryInterface.createTable("notice", {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comments: "唯一标识符",
      },
      user_id: {
        type: INTEGER,
        allowNull: false,
        comments: "用户id",
        references: {
          model: "users",
          key: "id",
          as: "users",
        },
      },
      title: {
        type: STRING,
        allowNull: false,
        comments: "标题",
      },
      content: {
        type: STRING,
        allowNull: false,
        comments: "内容",
      },
      is_show: {
        type: INTEGER,
        allowNull: false,
        comments: "是否显示",
        defaultValue: 1,
      },
      created_at: {
        type: DATE,
      },
      updated_at: {
        type: DATE,
      },
    });
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable("notice");
  },
};
